package com.sfzlot.dev.netty.bean.data;

import java.util.Date;

import com.sfzlot.dev.netty.bean.inf.Data;
import com.sfzlot.dev.netty.utils.ByteUtil;

/**
 * 设备登入信息请求体
 * v1版本为正常版本
 * v2版本为固化版本，序列号会一直为1
 * Created by pierr on 2017/5/30.
 */
public class DeviceLoginInData implements Data {
    
    private Date dataCollectTime;	// 数据采集时间
    private int serialNum;		// 登入流水号
    private String ICCID;			// ICCID号
    private String devicePwd;	//设备密码

    public Date getDataCollectTime() {
        return dataCollectTime;
    }

    public void setDataCollectTime(Date dataCollectTime) {
        this.dataCollectTime = dataCollectTime;
    }

    public int getSerialNum() {
        return serialNum;
    }

    public void setSerialNum(int i) {
        this.serialNum = i;
    }

    public String getICCID() {
        return ICCID;
    }

    public void setICCID(String ICCID) {
        this.ICCID = ICCID;
    }
    
	public String getDevicePwd() {
		return devicePwd;
	}

	public void setDevicePwd(String devicePwd) {
		this.devicePwd = devicePwd;
	}


	@Override
	public String toString() {
		return "DeviceLoginInData [dataCollectTime=" + dataCollectTime + ", serialNum=" + serialNum + ", ICCID=" + ICCID
				+ ", devicePwd=" + devicePwd + "]";
	}

	@Override
	public byte[] toBytes(){
		byte[] dateBytes = ByteUtil.timeToBytes(dataCollectTime);
		byte[] serialNumBytes = ByteUtil.shortToBytes(Integer.valueOf(serialNum).shortValue());
		byte[] ICCIDBytes = ByteUtil.stringToByte(ICCID, 20);
		byte[] devicePwdBytes = ByteUtil.stringToByte(devicePwd, 32);
		return ByteUtil.addAll(dateBytes, serialNumBytes, ICCIDBytes, devicePwdBytes);
	}

	@Override
	public String transData() {
		return "DeviceLoginInData(设备登入请求信息体) [dataCollectTime=" + dataCollectTime + ", serialNum=" + serialNum + ", ICCID=" + ICCID
				+ ",devicePwd=" + devicePwd + "]";
	}
}
